
  <style>
    .demo-reg-container {
      width: 320px;
      margin: 21px auto 0;
      margin-top: 25vh;
    }

    .demo-reg-other .layui-icon {
      position: relative;
      display: inline-block;
      margin: 0 2px;
      top: 2px;
      font-size: 26px;
    }
  </style>



<form class="layui-form" action="" method="post">
  <div class="demo-reg-container">
    <div class="layui-form-item">
      <div class="layui-input-wrap">
        <div class="layui-input-prefix">
          <i class="layui-icon layui-icon-vercode"></i>
        </div>
        <input type="text" name="uname" value="" placeholder="用户名"
               autocomplete="off" class="layui-input" id="reg-uname">
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-wrap">
        <div class="layui-input-prefix">
          <i class="layui-icon layui-icon-password"></i>
        </div>
        <input type="password" name="upwd"   placeholder="密码"
               class="layui-input" id="reg-password" lay-affix="eye">
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-wrap">
        <div class="layui-input-prefix">
          <i class="layui-icon layui-icon-password"></i>
        </div>
        <input type="password" name="confirmPassword"  id="confirmPassword"
               placeholder="确认密码"  class="layui-input" lay-affix="eye">
      </div>
    </div>
    <div class="layui-form-item">
      <input type="button" class="layui-btn layui-btn-fluid"  id="btnRegister" value="注册"></input>
    </div>
    <div class="layui-form-item demo-reg-other">
      <label>社交账号注册</label>
      <span style="padding: 0 21px 0 6px;">
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-qq" style="color: #3492ed;"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"
                                              style="color: #4daf29;"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo" style="color: #cf1900;"></i></a>
                </span>
      <a href="/index.php/login/login">登录已有帐号</a></span>
    </div>
  </div>
</form>
<script>
  $("#btnRegister").click(
          function () {
            var uname  = $("#reg-uname").val();
            var upwd = $("#reg-password").val();
            var upwd2 =$("#confirmPassword").val();
            if(uname==""){
              layer.msg("请输入用户名", {icon: 0})
            }else if(upwd==""){
              layer.msg("请输入密码",{icon: 2})
            }else if(upwd2==""){
              layer.msg("请输入确认密码",{icon: 2})
            }else if(upwd!=upwd2&&upwd!=null){
              layer.msg("两次密码输入不一致",{icon: 2})
            }else {
              $.post("/index.php/index/registerCheck", {
                "uname":uname,
                "upwd":upwd,
              },function (data,status) {
                layer.msg(data+"状态"+status);
                if(data==-1){
                  layer.msg("该用户已经存在，请重新输入用户名！");
                }else if(data==1) {
                  layer.msg("注册成功!")
                  window.location.href= "/index.php/login/login"
                }
              })
            }

          })
</script>
